package engine.gui;

import static engine.gui.BorderTile.*;

import engine.game.Manager;
import engine.graphics.Color4f;

public class Border extends ParentObject {

	private static final long serialVersionUID = 1L;
	
	private BorderTile[] tiles = new BorderTile[8] ; 
	
	public Border(Manager m, ParentObject parent) {
		super(m, parent);
		init(); 
	}
	
	public void init(){
		super.init();
		this.changeNormalColor(new Color4f(1,1,1,0));
		this.disableClicking(); 
		this.disableHovering();
	
		tiles[0] = new BorderTile(this.getManager(), (int)this.getMinX(), (int)this.getMinY()+THICKNESS, 
				THICKNESS, this.getObjectHeight()-THICKNESS*2); 
		tiles[1] = new BorderTile(this.getManager(), (int)this.getMinX()+THICKNESS, (int)this.getMaxY()-THICKNESS, 
				this.getObjectWidth()-THICKNESS*2, THICKNESS); 
		tiles[2] = new BorderTile(this.getManager(), (int)this.getMaxX()-THICKNESS, (int)this.getMinY()+THICKNESS, 
				THICKNESS, this.getObjectHeight()-THICKNESS*2); 
		tiles[3] = new BorderTile(this.getManager(), (int)this.getMinX()+THICKNESS, (int)this.getMinY(), 
				this.getObjectWidth()-THICKNESS*2, THICKNESS); 
		
		tiles[4] = new BorderTile(this.getManager(), (int)this.getMinX(), (int)this.getMaxY()-THICKNESS,
				THICKNESS, THICKNESS) ; 
		tiles[5] = new BorderTile(this.getManager(), (int)this.getMaxX()-THICKNESS, (int)this.getMaxY()-THICKNESS,
				THICKNESS, THICKNESS) ; 
		tiles[6] = new BorderTile(this.getManager(), (int)this.getMaxX()-THICKNESS, (int)this.getMinY(),
				THICKNESS, THICKNESS) ; 
		tiles[7] = new BorderTile(this.getManager(), (int)this.getMinX(), (int)this.getMinY(),
				THICKNESS, THICKNESS) ; 
		for(int i=0; i<this.tiles.length; i++){
			tiles[i].changeNormalColor(new Color4f(0.05f, 0.05f, 0.05f, 1.0f)) ; 
			this.addNewChild("tile_"+tiles[i].hashCode(), tiles[i]); 
		}
	}
	
	public BorderTile[] getAllTiles(){
		return this.tiles ; 
	}
	
	public BorderTile getLeftTile(){
		return this.tiles[0] ; 
	}

	public BorderTile getUpperTile(){
		return this.tiles[1] ; 
	}
	
	public BorderTile getRightTile(){
		return this.tiles[2] ; 
	}
	
	public BorderTile getLowerTile(){
		return this.tiles[3] ; 
	}
	
	public BorderTile getUpperLeftTile(){
		return this.tiles[4] ; 
	}
	
	public BorderTile getUpperRightTile(){
		return this.tiles[5] ; 
	}
	
	public BorderTile getLowerRightTile(){
		return this.tiles[6] ; 
	}
	
	public BorderTile getLowerLeftTile(){
		return this.tiles[7] ; 
	}
}
